Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up command handling in hdp.c/h #433

Merged
merged 2 commits into from
Sep 13, 2023

Conversation

derobins
Copy link
Member

  • Move list of commands inside hdp.c
  • Remove HDP_MASTER scheme
  • Tie command string & enum value together in a struct to keep in sync
  • Minor tidying

* Move list of commands inside hdp.c
* Remove HDP_MASTER scheme
* Tie command string & enum value together in a struct to keep in sync
* Minor tidying
@derobins derobins added Component - Tools Command-line tools like dumper and hdiff Type - Improvement Improvements that don't add a new feature or functionality Priority - 3. Low 🔽 Code cleanup, small feature change requests, etc. labels Sep 13, 2023
#ifdef HDP_MASTER
= {"help", "list", "dumpsds", "dumprig", "dumpvg", "dumpvd", "dumpgr"}
#endif /* HDP_MASTER */
;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved into hdp.c since it's not used anywhere else

typedef struct command_t {
const command_value_t value;
const char *name;
} command_t;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tying the enum value and string together into a struct ensures they will never be out of sync

Also return EXIT_FAILURE/SUCCESS instead of 1 and 0
if (cmd == BAD_COMMAND) {
printf("Invalid command: %s\n", argv[curr_arg]);
exit(EXIT_FAILURE);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before we printed the value of cmd (in code below), which would just be the sentinel NONE value, which is unhelpful.

break;
} /* end switch */
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Printing the enum value was unhelpful. Printing the string is better, which we do above.

@derobins
Copy link
Member Author

Test failures are due to GitHub flakiness and aren't real

@derobins derobins merged commit e095a6f into HDFGroup:master Sep 13, 2023
44 checks passed
@derobins derobins deleted the hdp_header_cleanup branch March 3, 2024 20:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component - Tools Command-line tools like dumper and hdiff Priority - 3. Low 🔽 Code cleanup, small feature change requests, etc. Type - Improvement Improvements that don't add a new feature or functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants